<template>
  <Card style="height:900px">
    <div>
      <p slot="title" style="color: red;font-size: large;">
        <Icon type="pinpoint"></Icon>
        宝生审批结果
      </p>
      <Row>
        <DatePicker type="date" v-model="startCreatedDate" placeholder="进件日期(起)" style="width: 200px"></DatePicker>—
        <DatePicker type="date" v-model="endCreatedDate" placeholder="进件日期(止)" style="width: 200px"></DatePicker>&nbsp;&nbsp;
        <Input v-model="custName" style="width: 100px;" placeholder="客户姓名"></Input>&nbsp;&nbsp;
        <Input v-model="custCardNo" style="width: 200px;" placeholder="身份证号码"></Input>&nbsp;&nbsp;
        <!-- <Input v-model="channelName" style="width: 100px;" placeholder="处理状态"></Input>&nbsp;&nbsp; -->
        <!-- <Select v-model="pushCondition.pushStatus" class="v-select-wrapper" style="width:150px" name="pushStatus">
                        <Option v-for="item in statusList" :value="item.key" :key="item.key">{{ item.label }}</Option>
        </Select> -->
        <Button type="primary" @click="queryPage" style="margin-left: 10px;">查询</Button>
      </Row>
      <Table stripe border :columns="columns1" :data="resultsData" style="margin-top: 10px;"></Table>
    </div>
     <Modal v-model="modal1" title="更换资金源"  :scrollable="true" @on-ok="updateBsFund"  >
            <Form ref="downForm" :model="listDownCondition" :label-width="120" inline>
                <div class="list-query-popup-div">
                     <FormItem label="进件编号:" prop="">
                          <Input  v-model="listDownCondition.loanId" style="width: 200px;" disabled/>
                     </FormItem>
                </div>
                <div class="list-query-popup-div">
                     <FormItem label="客户名称:" prop="">
                          <Input  v-model="listDownCondition.custName" style="width: 200px;" disabled/>
                     </FormItem>
                </div>
                <div class="list-query-popup-div">
                  <FormItem label="身份证号:" prop="">
                      <Input  v-model="listDownCondition.custIdCard" style="width: 200px;" disabled/>
                     </FormItem>
                </div>
                 <div class="list-query-popup-div">
                    <FormItem label="银行卡号:" prop="">
                        <Input  v-model="listDownCondition.receiveAcctNo" style="width: 200px;" disabled/>
                     </FormItem>
                </div>
                <div class="list-query-popup-div">
                    <FormItem label="产品:" prop="">
                        <Input  v-model="listDownCondition.productTypeName" style="width: 200px;" disabled/>
                     </FormItem>
                </div>
                <div class="list-query-popup-div">
                    <FormItem label="贷款金额:" prop="">
                        <Input  v-model="listDownCondition.principalAmtAct" style="width: 200px;" disabled/>
                     </FormItem>
                </div>
                <div class="list-query-popup-div">
                    <FormItem label="期限:" prop="">
                        <Input  v-model="listDownCondition.term" style="width: 200px;" disabled/>
                     </FormItem>
                </div>
                <div class="list-query-popup-div">
                    <FormItem label="资金方:" prop="">
                        <Select v-model="listDownCondition.fundCode" class="v-select-wrapper" style="width:150px" name="fundCode">
                            <Option v-for="item in fundList" :value="item.fundCode" :key="item.fundCode">{{ item.fundName }}</Option>
                        </Select>
                     </FormItem>
                </div>
            </Form>
        </Modal>
  </Card>
</template>
<script>

export default {
  data () {
    return {
      $ajax: null,
      modal1: false,
      path: this.$route.path,
      totalNumber: 0, // 总记录数
      currentPage: 1, // 当前页码
      pageSize: 20, // 页大小
      custName: null,
      fundList: [],
      listDownCondition: {},
      custCardNo: null,
      screenshotsBy: null,
      startCreatedDate: null,
      endCreatedDate: null,
      screenshotsStartDate: null,
      screenshotsEndDate: null,
      resultsData: [],
      columns1: [
        {
          type: 'index',
          title: '序号',
          width: 60
        },
        {
          title: '贷款编号',
          key: 'loanId'
        },
        {
          title: '客户姓名',
          key: 'custName'
        },
        {
          title: '证件号码',
          key: 'custIdCard'
        },
        {
          title: '产品名称',
          key: 'description'
        },
        {
          title: '期数',
          key: 'term'
        },
        {
          title: '货款金额',
          key: 'principalAmtAct'
        },
        {
          title: '推送时间',
          key: 'createdDate',
          render: (h, params) => {
            var vm = this
            return h('div', [
              h('span', vm.$util.formatTime(params.row.createdDate))
            ])
          }
        },
        {
          title: '返回结果',
          key: 'status'
        },
        {
          title: '返回结果时间',
          key: 'updatedDate',
          render: (h, params) => {
            var vm = this
            return h('div', [
              h('span', vm.$util.formatTime(params.row.updatedDate))
            ])
          }
        },
        {
          title: '备注',
          key: 'desc'
        },
        {
          title: '操作',
          key: 'action',
          align: 'center',
          width: 200,
          render: function (h, param) {
            var vm = this
            var statre = param.row.status
            return h('div', {}, [
              //
              (statre === '未处理' || statre === '异常' || statre === '处理中止') && statre !== '处理失败' && statre !== '处理中' && statre !== '处理成功' &&
              h('Button', {
                props: {
                  type: 'info',
                  size: 'small'
                },
                style: {
                  fontSize: '12px'
                },
                on: {
                  'click' () {
                    var params = {}
                    params.loanId = param.row.loanId
                    params.insuranceId = param.row.insuranceId
                    vm.$ajax.post(vm.$appContext.marvels_core_approve + '/approve/bsRepayPush/service/toBsPush', params).then(re => {
                      var data = re.data
                      if (data.data) {
                        vm.queryPage()
                      } else {
                        vm.$Message.warning('重新推送失败，请联系IT人员!')
                      }
                    }).catch(er => {
                      // console.log(er)
                      vm.$Message.error(er.message)
                    })
                  }
                }
              }, '重新推送'),
              statre !== '处理成功' && statre !== '处理中' && statre !== '未处理' && statre === '处理失败' && statre !== '处理中止' && statre !== '异常' && h('Button', {
                props: {
                  type: 'info',
                  size: 'small'
                },
                style: {
                  marginLeft: '10px'
                },
                on: {
                  'click' () {
                    var params = {}
                    params.loanId = param.row.loanId
                    params.insuranceId = param.row.insuranceId
                    vm.$ajax.post(vm.$appContext.marvels_core_approve + '/approve/bsRepayPush/service/selectBsFund', params).then(re => {
                      vm.modal1 = true
                      var data = re.data
                      vm.listDownCondition = data.data
                      vm.fundList = data.data.fundList
                    }).catch(er => {
                      vm.$Message.error(er.message)
                    })
                  }
                }

              }, '更改资金源')

            ])
          }.bind(this)
        }

      ]
    }
  },

  methods: {
    initPage () {
      this.queryPage()
    },
    updateBsFund () {
      const vm = this
      var params = {
        pageNum: vm.currentPage,
        pageSize: vm.pageSize,
        custCardNo: vm.custCardNo,
        screenshotsBy: vm.screenshotsBy,
        custName: vm.custName,
        startCreatedDate: vm.startCreatedDate,
        endCreatedDate: vm.endCreatedDate,
        screenshotsStartDate: vm.screenshotsStartDate,
        screenshotsEndDate: vm.screenshotsEndDate,
        loanId: this.listDownCondition.loanId,
        fundCode: this.listDownCondition.fundCode
      }
      vm.$ajax.post(vm.$appContext.marvels_core_approve + 'approve/bsRepayPush/service/updateBsFund', params).then(re => {
        var data = re.data
        if (data.data > 0) {
          this.queryPage()
        } else {
          vm.$Message.warning('更换资金源失败，请选择资金源!')
        }
      }).catch(er => {

      })
    },
    queryPage () {
      const vm = this
      var params = {
        pageNum: vm.currentPage,
        pageSize: vm.pageSize,
        custCardNo: vm.custCardNo,
        screenshotsBy: vm.screenshotsBy,
        custName: vm.custName,
        startCreatedDate: vm.startCreatedDate,
        endCreatedDate: vm.endCreatedDate,
        screenshotsStartDate: vm.screenshotsStartDate,
        screenshotsEndDate: vm.screenshotsEndDate
      }
      // console.log(params)
      vm.$ajax.post(vm.$appContext.marvels_core_approve + 'approve/bsRepayPush/service/selectResults', params).then(re => {
        var data = re.data
        vm.resultsData = data.data.list
      }).catch(er => {

      })
    }

  },

  created () {
    // 初始化当前页面请求对象实例
    this.$ajax = this.$util.ajax()
    this.initPage()
  }
}
</script>

<style lang="less">
@import '../../../styles/common.less';
@import '../../../styles/table.less';
</style>
